<?php
/**
 * 标准动作模型
 * @author jianhui
 *
 */
class actionModel extends MY_Model{
    function actionModel(){
        parent::MY_Model();
        $this->table = 'action';
    }
    /**
     * 包装数据
     * @param array $list
     * @return array
     */
    function packing($list = array()){
        $this->load->model('timeUnitModel');
        $timeUnitList = $this->timeUnitModel->getCacheData('timeUnitList');
        $status = array(1=>'开启',0=>'关闭');
        foreach ($list as $k => $v){
            $list[$k]['timeUnitStr'] = isset($timeUnitList[$v['year']][$v['timeUnit']]) ? $timeUnitList[$v['year']][$v['timeUnit']] : '';
            $list[$k]['statusStr'] = isset($status[$v['status']]) ? $status[$v['status']] : '';
        }
        return $list;   
    }
    /**
     * 获取激活的标准动作列表
     * @param array $timeUnit
     * @param number $type
     * @param string $year
     */
    function getActiveList($timeUnit, $type = 1, $year=''){
        $year || $year = date('Y');
        $findList = $this->getList(array('timeUnit'=>$timeUnit,'year'=>$year, 'status'=>1, 'type'=>$type), null, null, '', 'orderNum asc,id asc');
        $list = array();
        foreach ($findList as $k => $v){
            $list[$k] = $v['name'];
        }
        return $list;
    }
}